﻿<phone:PhoneApplicationPage
    x:Class="BlogApp.WP8.View.LoadingPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    Background="{StaticResource SplashBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding MainViewModel, Source={StaticResource Locator}}">

    <!--<i:Interaction.Triggers>
        <i:EventTrigger>
            <i:InvokeCommandAction Command="{Binding LoadCategoriesCommand, Mode=OneWay}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>-->

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn" />
            </toolkit:NavigationInTransition.Backward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut" />
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut" />
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>



    <Grid x:Name="LayoutRoot" Background="{StaticResource SplashBrush}">
        <i:Interaction.Triggers>
            <i:EventTrigger>
                <ec:GoToStateAction StateName="Initialized"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="InitializationStates" ec:ExtendedVisualStateManager.UseFluidLayout="True">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:1">
                        <VisualTransition.GeneratedEasingFunction>
                            <PowerEase EasingMode="EaseOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Uninitialized"/>
                <VisualState x:Name="Initialized">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="-150" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="Logo" d:IsOptimized="True"/>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="GrdProgress" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <VisualStateManager.CustomVisualStateManager>
            <ec:ExtendedVisualStateManager/>
        </VisualStateManager.CustomVisualStateManager>

        <Image Source="/Assets/SplashScreenImage.png" x:Name="Logo" RenderTransformOrigin="0.5,0.5"  Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibilityConverter}}" >
            <Image.RenderTransform>
                <CompositeTransform/>
            </Image.RenderTransform>
        </Image>
        <StackPanel Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibilityConverter}}" 
			VerticalAlignment="Center" 
			Opacity="0"
			x:Name="GrdProgress" >
            <ProgressBar IsIndeterminate="{Binding IsLoading}" Foreground="White" />
            <TextBlock Text="{Binding LocalizedResources.MainPageLoadingText, Source={StaticResource LocalizedStrings}}" 
				HorizontalAlignment="Center"
				Margin="24"
                Foreground="White"/>
        </StackPanel>



    </Grid>

</phone:PhoneApplicationPage>